package com.ktjiaoyu.t313.service;

import com.ktjiaoyu.t313.dao.UserDao;
import com.ktjiaoyu.t313.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    /*public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }*/

    @Override
    public List<User> findUserList() {

        return userDao.findUserList();
    }


    @Transactional
    @Override
    public int deleteUserById(int id) {

        if(userDao.deleteUserById(id)==1){
            throw new RuntimeException("删除出现异常！");  //出现异常事务进行回滚
        }

        return 1;
    }
}
